<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dubbo 核心知识点解析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 1px solid transparent;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            border-color: #667eea;
        }
        
        .number-circle {
            width: 48px;
            height: 48px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: bold;
            font-size: 20px;
            flex-shrink: 0;
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 2px 8px;
            border-radius: 4px;
            display: inline-block;
            font-weight: 500;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            margin-top: -0.2rem;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        
        .icon-feature {
            width: 60px;
            height: 60px;
            background: rgba(102, 126, 234, 0.1);
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #667eea;
            font-size: 24px;
            margin-bottom: 1rem;
        }
        
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animate-fadeInUp {
            animation: fadeInUp 0.6s ease-out;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6 text-center">
            <h1 class="text-5xl font-bold mb-4 animate-fadeInUp">Dubbo 核心知识点解析</h1>
            <p class="text-xl opacity-90 max-w-2xl mx-auto animate-fadeInUp" style="animation-delay: 0.2s">
                深入理解分布式服务框架的运行机制与设计原理
            </p>
            <div class="mt-8 flex justify-center space-x-8 animate-fadeInUp" style="animation-delay: 0.4s">
                <div class="text-center">
                    <i class="fas fa-network-wired text-3xl mb-2"></i>
                    <p class="text-sm">高性能通信</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-balance-scale text-3xl mb-2"></i>
                    <p class="text-sm">负载均衡</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-shield-alt text-3xl mb-2"></i>
                    <p class="text-sm">高可用保障</p>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="container mx-auto px-6 py-12">
        <!-- 架构概览 -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-8 card-hover">
            <h2 class="text-3xl font-bold mb-6 text-gray-800 section-title">
                <i class="fas fa-sitemap mr-3 text-purple-600"></i>Dubbo 架构概览
            </h2>
            <div class="mermaid">
                graph TB
                    subgraph "服务治理"
                        A[生产者 Provider] -->|注册服务| B[注册中心 ZooKeeper]
                        C[消费者 Consumer] -->|订阅服务| B
                        B -->|推送地址| C
                        C -->|调用| A
                        A -->|统计| D[监控中心 Monitor]
                        C -->|统计| D
                    end
                    
                    style A fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                    style C fill:#764ba2,stroke:#fff,stroke-width:2px,color:#fff
                    style B fill:#f093fb,stroke:#fff,stroke-width:2px,color:#fff
                    style D fill:#f5576c,stroke:#fff,stroke-width:2px,color:#fff
            </div>
        </div>

        <!-- 问题解答部分 -->
        <div class="grid md:grid-cols-2 gap-8 mb-12">
            <!-- 问题1 -->
            <div class="bg-white rounded-2xl shadow-lg p-8 card-hover">
                <div class="flex items-start mb-4">
                    <div class="number-circle">1</div>
                    <h3 class="text-xl font-bold ml-4 text-gray-800 flex-1">
                        当 ZooKeeper 挂了之后，生产者和消费者之间还能通信吗？
                    </h3>
                </div>
                <div class="pl-16">
                    <div class="mb-4">
                        <span class="highlight-box">可以通信</span>
                    </div>
                    <p class="text-gray-600 leading-relaxed mb-4">
                        <span class="drop-cap">当</span>启动 Dubbo 容器时，消费者会从 ZooKeeper 拉取注册的生产者地址列表，并将其缓存在本地。每次发起调用时，都会按照本地的地址列表，以负载均衡的策略进行调用。
                    </p>
                    <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4 rounded">
                        <p class="text-sm text-yellow-800">
                            <i class="fas fa-exclamation-triangle mr-2"></i>
                            注意：如果 ZooKeeper 挂掉，后续新的生产者将无法被消费者发现。
                        </p>
                    </div>
                </div>
            </div>

            <!-- 问题2 -->
            <div class="bg-white rounded-2xl shadow-lg p-8 card-hover">
                <div class="flex items-start mb-4">
                    <div class="number-circle">2</div>
                    <h3 class="text-xl font-bold ml-4 text-gray-800 flex-1">
                        当监控中心 Monitor 挂了之后，生产者和消费者之间还能通信吗？
                    </h3>
                </div>
                <div class="pl-16">
                    <div class="mb-4">
                        <span class="highlight-box">不影响通信</span>
                    </div>
                    <p class="text-gray-600 leading-relaxed">
                        监控中心主要起到收集数据的作用。监控中心宕机只会影响数据采集，不会影响生产者和消费者之间的正常通信。
                    </p>
                    <div class="mt-4 flex items-center text-green-600">
                        <i class="fas fa-check-circle mr-2"></i>
                        <span class="text-sm">服务调用链路独立于监控系统</span>
                    </div>
                </div>
            </div>
        </div>

        <!-- ZooKeeper 存储结构 -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-8 card-hover">
            <div class="flex items-start mb-6">
                <div class="number-circle">3</div>
                <h3 class="text-2xl font-bold ml-4 text-gray-800 flex-1">
                    ZooKeeper 如何存储生产者和消费者信息？
                </h3>
            </div>
            
            <div class="pl-16">
                <p class="text-gray-600 mb-6">ZooKeeper 采用树状结构存储相关信息，创建 znode 节点来保存数据。</p>
                
                <div class="bg-gray-50 rounded-xl p-6 mb-6">
                    <div class="mermaid">
                        graph TD
                            A[/dubbo] --> B[com.foo.BarService]
                            B --> C[providers]
                            B --> D[consumers]
                            B --> E[configurators]
                            B --> F[routers]
                            
                            C --> G[provider1 URL]
                            C --> H[provider2 URL]
                            D --> I[consumer1 URL]
                            D --> J[consumer2 URL]
                            
                            style A fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                            style B fill:#764ba2,stroke:#fff,stroke-width:2px,color:#fff
                            style C fill:#f093fb,stroke:#fff,stroke-width:2px,color:#fff
                            style D fill:#f5576c,stroke:#fff,stroke-width:2px,color:#fff
                    </div>
                </div>
                
                <div class="space-y-4">
                    <div class="flex items-start">
                        <div class="icon-feature">
                            <i class="fas fa-server"></i>
                        </div>
                        <div class="ml-4">
                            <h4 class="font-semibold text-gray-800 mb-2">服务提供者启动时</h4>
                            <p class="text-gray-600">向 <code class="bg-purple-100 px-2 py-1 rounded text-purple-700">/dubbo/com.foo.BarService/providers</code> 目录下写入自己的 URL 地址</p>
                        </div>
                    </div>
                    
                    <div class="flex items-start">
                        <div class="icon-feature">
                            <i class="fas fa-user"></i>
                        </div>
                        <div class="ml-4">
                            <h4 class="font-semibold text-gray-800 mb-2">服务消费者启动时</h4>
                            <p class="text-gray-600">订阅 <code class="bg-purple-100 px-2 py-1 rounded text-purple-700">/dubbo/com.foo.BarService/providers</code> 目录下的提供者 URL 地址，并向 <code class="bg-purple-100 px-2 py-1 rounded text-purple-700">/dubbo/com.foo.BarService/consumers</code> 目录下写入自己的 URL 地址</p>
                        </div>
                    </div>
                    
                    <div class="flex items-start">
                        <div class="icon-feature">
                            <i class="fas fa-chart-line"></i>
                        </div>
                        <div class="ml-4">
                            <h4 class="font-semibold text-gray-800 mb-2">监控中心启动时</h4>
                            <p class="text-gray-600">订阅 <code class="bg-purple-100 px-2 py-1 rounded text-purple-700">/dubbo/com.foo.BarService</code> 目录下的所有提供者和消费者 URL 地址</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 负载均衡策略 -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-8 card-hover">
            <div class="flex items-start mb-6">
                <div class="number-circle">4</div>
                <h3 class="text-2xl font-bold ml-4 text-gray-800 flex-1">
                    Dubbo 的负载均衡策略
                </h3>
            </div>
            
            <div class="pl-16 grid md:grid-cols-2 gap-6">
                <div class="bg-gradient-to-br from-purple-50 to-pink-50 p-6 rounded-xl">
                    <div class="flex items-center mb-3">
                        <i class="fas fa-random text-purple-600 text-2xl mr-3"></i>
                        <h4 class="font-bold text-gray-800">Random LoadBalance</h4>
                    </div>
                    <p class="text-gray-600 text-sm">随机调用策